import StringKeyObject from '../models/string-key-object';
import RouteMapManager from './route-map-manager';

/**
 * IMPORTANT!!!
 * Always keep it in mind that permission / authentication / authorization MUST be applied on server side first.
 * Any client side check is for user experience ONLY.
 * NEVER TRUST CLIENT!
 */
export default class RouteMapConfig {
  // DO NOT USE STATIC!
  // If static field value includes variable would cause runtime error: Uncaught ReferenceError: Cannot access 'RouteMapManager' before initialization.
  //
  // readonly config: StringKeyObject = {
  //   // region: The configuration allows anonymous access.
  //   [`${AuthenticationRouting.routeName}/${AuthenticationRouting.loginRouteName}`]: RouteMapManager.permitAll,
  //   // endregion

  //   // region: The configuration allows authenticated access.
  //   [HomeRouting.routeName]: RouteMapManager.isAuthenticated,
  //   // [`${UserRouting.routeName}/${UserRouting.listRouteName}`]: RouteMapManager.isAuthenticated,
  //   [`${UserRouting.routeName}/**`]: RouteMapManager.isAuthenticated,
  //   // endregion

  //   // region: The configuration only allows account group user and admin access.
  //   // endregion

  //   // region: The configuration allows account group admin access.
  //   // endregion
  // };

  static getMapping(): StringKeyObject {
    return {
      // region: The configuration allows anonymous access.
      '/authentication/login': RouteMapManager.permitAll,
      // endregion

      // region: The configuration allows authenticated access.
      '/home': RouteMapManager.isAuthenticated,
      '/user/**': RouteMapManager.isAuthenticated,
      // endregion

      // region: The configuration only allows account group user and admin access.
      // endregion

      // region: The configuration allows account group admin access.
      // endregion
    };
  }
}